"""
1.Html下载器----用来下载网页
2.模块----requests...
3.接口----download(url)
"""
import requests
class HtmlDownloader(object):

    def download(self,url):
        if url is None:
            return None
        user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
        headers = {"User-Agent": user_agent}
        r = requests.get(url, headers=headers)
        if r.status_code == 200:
            r.encoding = "utf-8"
            return r.text
        return None

# obj = HtmlDownloader()
# print(
#     obj.download("
        # https://baike.baidu.com/item/%E7%BD%91%E7%BB%9C%E7%88%AC%E8%99%AB%E7%A8%8B%E5%BA%8F/449844?fr=aladdin")
# )